<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <ul>
        <li>菜坤坤</li>
        <li>大碗面</li>
        <li id="ff">锋锋</li>
    </ul>

    <script>
        // querySelectorAll 获取所有元素 下标从0开始
        var li = document.querySelectorAll("li")
        console.log(li);
        li[0].style.background = "yellow"
        // nth-of-type  选择相应的标签下的某一个具体标签 从1开始
        var lii = document.querySelector("ul li:nth-of-type(2)")
        console.log(lii);
        lii.style.background = "red"
        // 获取单个元素
        var ff = document.querySelector("#ff")
        ff.style.background = "green"
    </script>
</body>
</html>